 package org.dlsu.mt.parser.generation;
import java.util.Vector;

public class PhraseList
{
	private Vector<ListElement> list;
	private int numElements;
	
	public PhraseList()
	{
		list = new Vector();
		numElements = 0;
	}
	
	public boolean addElement(ListElement e)
	{
		if(list.add(e))
		{
			numElements++;
			return true;
		}
		else
			return false;
	}
	
	public ListElement getElement(int index)
	{
		if(index<=numElements)
			return list.get(index);
		else
			return null;
	}
	
	public boolean removeElement(int i)
	{
		if(i<=numElements)
		{
			list.remove(i);
			numElements--;
			return true;
		}
		return false;
	}
	
	public int getNumElements()
	{
		return numElements;
	}
	
	public String toString()
	{
		StringBuffer temp = new StringBuffer();
		for(int i=0;i<list.size();i++)
		{
			String x = list.get(i).toString();
			if(x.length()>0)
			{
				temp.append(x);
				if(i == list.size()-1)
					temp.append("\n");
				else
					temp.append(",\n");
			}
		}
		return temp.toString();
	}
}